<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function random(min, max) {
        const r = Math.random() * (max - min) + min;
        return Math.round(r);
      }

      console.log(random(2, 4)); //[2,4]
      console.log(random(4, 9)); //[4,9]
    </script>
  </body>
</html>
